/*
 * Copyright 2013 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.wizardpager.wizard.model;

import java.util.ArrayList;

import android.support.v4.app.Fragment;

import com.example.android.wizardpager.wizard.ui.AddressFragment;

/**
 * A page offering the user a number of non-mutually exclusive choices.
 */
public class AddressPage extends Page {
	
	
	
	private String tip, label;
    public AddressPage(ModelCallbacks callbacks, String title, String Tip) {
        super(callbacks, title);
        tip = Tip;
        label = "";
    }

    @Override
    public Fragment createFragment() {
        return AddressFragment.create(getKey());
    }

    @Override
    public void getReviewItems(ArrayList<ReviewItem> dest) {      

    	StringBuilder sb = new StringBuilder();

        String s = mData.getString(Page.TEXT_DATA_KEY);
        if (s != null && s.length() > 0) {
            
                sb.append(s);
        }

        dest.add(new ReviewItem(getTitle(), sb.toString(), getKey()));
    }
    
    @Override
    public boolean isCompleted() {
    	double d1 = mData.getDouble(Page.LAT_DATA_KEY);
    	double d2 = mData.getDouble(Page.LON_DATA_KEY);
        return d1!= 0 && d2!=0;
    }

    public String getLabel() {
		return label;
	}
	
	public AddressPage setLabel(String Label) {
		label = Label;
        return this;
    }
	
	public String getTip() {
				
		if(isRequired())
		{
			return tip;
		}
		else
		{
			return tip;
		}
	}
	
	public String getAddressData()
    {
    	return mData.getString(Page.TEXT_DATA_KEY,"");
    }
	
	public double getLatitudeData() {
		return mData.getDouble(Page.LAT_DATA_KEY);
	}
	
	public double getLongitudeData() {
		return mData.getDouble(Page.LON_DATA_KEY);
	}
}
